package com.helloSpringBoot.controller;

import com.helloSpringBoot.vo.ResultObj;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@CrossOrigin
public class mockController {

    int count =1;
    @RequestMapping(value = "/test/exec", produces = "text/plain;charset=UTF-8",method= RequestMethod.POST)
    @ResponseBody
    public ResultObj postmock(@RequestBody String request)  {
        System.out.println("这是第"+count+"次，接收到请求："+request);
        count++;
        ResultObj ResultObj = new  ResultObj();
        String msg = "这是第"+count+"次回复";
        if(count==10){
            System.out.println(10);
        }
        else {
            System.out.println(120);
        }

        ResultObj.setData(msg);
        return ResultObj;
    }


    @RequestMapping(value = "/test/exec/get", produces = "text/plain;charset=UTF-8",method= RequestMethod.GET)
    @ResponseBody
    public ResultObj getmock()  {
        System.out.println("这是第"+count+"次，接收到请求：这是个get请求");
        count++;
        ResultObj ResultObj = new  ResultObj();
        String msg = "这是第"+count+"次回复";
        if(count==10){
            System.out.println(10);
        }
        else {
            System.out.println(120);
        }
        ResultObj.setData(msg);
        return ResultObj;
    }

    @RequestMapping(value = "/test/exec/get2", produces = "text/plain;charset=UTF-8",method= RequestMethod.GET)
    @ResponseBody
    public ResultObj getmock2()  {
        System.out.println("这是第"+count+"次，接收到请求：这是个get请求");
        count++;
        ResultObj ResultObj = new  ResultObj();
        String msg = "这是第"+count+"次回复";
        if(count==10){
            System.out.println(10);
        }
        else {
            System.out.println(120);
        }
        ResultObj.setData(msg);
        return ResultObj;
    }

    @RequestMapping(value = "/test/exec/get3", produces = "text/plain;charset=UTF-8",method= RequestMethod.GET)
    @ResponseBody
    public ResultObj getmock3()  {
        System.out.println("这是第"+count+"次，接收到请求：这是个get请求");
        count++;
        ResultObj ResultObj = new  ResultObj();
        String msg = "这是第"+count+"次回复";
        if(count==10){
            System.out.println(10);
        }
        else {
            System.out.println(120);
        }
        ResultObj.setData(msg);
        return ResultObj;
    }

    @RequestMapping(value = "/test/exec/get4", produces = "text/plain;charset=UTF-8",method= RequestMethod.GET)
    @ResponseBody
    public ResultObj getmock4()  {
        System.out.println("这是第"+count+"次，接收到请求：这是个get请求");
        count++;
        ResultObj ResultObj = new  ResultObj();
        String msg = "这是第"+count+"次回复";
        if(count==10){
            System.out.println(10);
        }
        else {
            System.out.println(120);
        }
        ResultObj.setData(msg);
        return ResultObj;
    }

    @RequestMapping(value = "/test/exec/get5", produces = "text/plain;charset=UTF-8",method= RequestMethod.GET)
    @ResponseBody
    public ResultObj getmock5()  {
        System.out.println("这是第"+count+"次，接收到请求：这是个get请求");
        count++;
        ResultObj ResultObj = new  ResultObj();
        String msg = "这是第"+count+"次回复";
        if(count==10){
            System.out.println(10);
        }
        else {
            System.out.println(120);
        }
        ResultObj.setData(msg);
        return ResultObj;
    }


}